{% extends './layout.html' %} {% block title %} {{ title }} {% endblock %} {% block body %}
<div class="layout_cont">
	<form class="layui-form" action="" layui-filter="chapterForm">
		<div class="layui-form-item">
			<label class="layui-form-label">章节标题</label>
			<div class="layui-input-block">
				<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" onfocus="inputFocus(this)" oninput="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit lay-filter="add">立即提交</button>
				<button type="button" class="layui-btn layui-btn-primary" id="editReturn">返回</button>
			</div>
		</div>
	</form>
</div>
{% endblock %} {% block scripts %}
<script src="/public/lib/socket.io.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var inputFocus = function(event) {
		console.log(event.value.replace('\w'));
		if (event.value) {

		}
		//console.log(event);
	}
	var inputBlur
	var inputInput = function() {

	}
	var socket = io.connect('http://localhost:4000/user');
	layui.use(['form'], function() {
		var $ = layui.jquery;
		var form = layui.form;
		socket.on('message', function(data) {
			console.log(data);
		});
		//监听提交
		form.on('submit(add)', function(data) {
			socket.send(data.field.title);
			return false;
		});
	});
</script>
{% endblock %}
